package pl.shenlon.poker.gui;

import java.awt.Color;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;

import net.miginfocom.swing.MigLayout;
import pl.shenlon.assets.Assets;
import pl.shenlon.poker.cards.Hand;

public class TableComponent extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 4851446413239615910L;

	private HandComponent playerAHand, playerBHand, tableCards;

	private JLabel potLabel, betLabel;

	public TableComponent() {
		initComponent();
	}

	public Hand getPlayerAHand() {
		return playerAHand.getHand();
	}

	public Hand getPlayerBHand() {
		return playerBHand.getHand();
	}

	public Hand getTableCards() {
		return tableCards.getHand();
	}

	private void initComponent() {
		playerAHand = new HandComponent();
		playerBHand = new HandComponent();
		tableCards = new HandComponent();
		potLabel = new JLabel("Pula $0");
		betLabel = new JLabel("Zakład $0");

		setLayout(new MigLayout());

		Font potLabelFont = potLabel.getFont();
		potLabel.setFont(new Font(potLabelFont.getName(), potLabelFont
				.getStyle(), 20));
		betLabel.setFont(potLabel.getFont());

		add(betLabel, "left");
		add(potLabel, "right, wrap -10");
		add(playerBHand, "span, center, wrap 20");
		add(tableCards, "span, center, wrap 20");
		add(playerAHand, "span, center, wrap 20");

		setBorder(BorderFactory.createLineBorder(
				(Color) Assets.get("@colours/table_border"),
				(Integer) Assets.get("@layout/table_border_width")));
	}

	public void setBetCash(int cash) {
		betLabel.setText("Zakład $" + cash);
	}

	public void setPlayerAHand(Hand hand) {
		playerAHand.setHand(hand);
	}

	public void setPlayerBHand(Hand hand) {
		playerBHand.setHand(hand);
	}

	public void setPotCash(int cash) {
		potLabel.setText("Pula $" + cash);
	}

	public void setTableCards(Hand hand) {
		tableCards.setHand(hand);
	}
}